package com.rental.web.controller;

import com.alibaba.nacos.plugin.auth.constant.Constants;
import com.rental.common.login.GetIdByToken;
import com.rental.common.result.AjaxResult;
import com.rental.common.util.AuthContextHolder;
import com.rental.model.entity.chargeRecord.ChargeRecord;
import com.rental.web.service.ChargeRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Tag(name = "充值记录模块")
@RequestMapping("/charge-record")
public class ChargeRecordController {
    @Autowired
    private ChargeRecordService chargeRecordService;

    /**
     * 公众号广告出租
     * @param chargeRecord
     * @return
     */
    @Operation(summary = "公众号广告出租")
    @GetIdByToken
    @PostMapping("/advertising")
    public AjaxResult<Boolean> advertising(@RequestBody ChargeRecord chargeRecord) {
        Long userId = AuthContextHolder.getUserId();
        chargeRecord.setUid(userId);
        return AjaxResult.success(chargeRecordService.advertising(chargeRecord,userId));
    }
    /**
     * 直连加速
     * @param chargeRecord
     * @return
     */
    @Operation(summary = "直连加速")
    @GetIdByToken
    @PostMapping("/connectWay")
    public AjaxResult<Boolean> connectWay(@RequestBody ChargeRecord chargeRecord) {
        Long userId = AuthContextHolder.getUserId();
        chargeRecord.setUid(userId);
        return AjaxResult.success(chargeRecordService.connectWay(chargeRecord, userId));
    }

    /**
     * 微博广告出租
     * @param chargeRecord
     * @return
     */
    @Operation(summary = "微博广告出租")
    @GetIdByToken
    @PostMapping("/advertisingWeiBo")
    public AjaxResult<Boolean> advertisingWeiBo(@RequestBody ChargeRecord chargeRecord) {
        Long userId = AuthContextHolder.getUserId();
        chargeRecord.setUid(userId);
        return AjaxResult.success(chargeRecordService.advertisingWeiBo(chargeRecord,userId));
    }

    /**
     * 每日签到
     * @return
     */
    @Operation(summary = "每日签到")
    @GetIdByToken
    @GetMapping("/sign")
    public AjaxResult<Boolean> sign() {
        Long userId = AuthContextHolder.getUserId();
        return AjaxResult.success(chargeRecordService.sign(userId));
    }

    /**
     * 查询加速值明细
     * @return
     */
    @Operation(summary = "查询加速值明细")
    @GetIdByToken
    @PostMapping("/getChargeRecordInfo")
    public AjaxResult<List<ChargeRecord>> getChargeRecordInfo() {
        Long userId = AuthContextHolder.getUserId();
        return AjaxResult.success(chargeRecordService.getChargeRecordInfo(userId));
    }

    /***
     * 实名认证
     * @return
     */
    @Operation(summary = "实名认证")
    @GetIdByToken
    @GetMapping("/toRegister")
    public AjaxResult<String> toRegister(@RequestParam("idCard") String idCard,@RequestParam("realName") String realName){
        Long userId = AuthContextHolder.getUserId();
        return AjaxResult.success(chargeRecordService.toRegister(userId,idCard,realName));
    }
}
